Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds ability to ignore parse exception console messages #65

Merged

Conversation

dambrosio
Copy link
Contributor

@dambrosio dambrosio commented Jan 23, 2025

Allows a user to specify the doxylink_parse_error_ignore_regexes configuration value in the Sphinx conf.py file to prevent doxylink tag parsing from printing specific messages to console. The value shall be a list of regular expressions that can be used to ignore specific errors reported from the parser. Default is [] for backwards compatibility.

In this example, the first error message will no longer be logged:

doxylink_parse_error_ignore_regexes = [r"DEFINE.*"]

Skipping function company::DEFINE_bool(show, false, "Enable visualization"). Error reported from parser was: Expected ')', found ','  (at char 12), (line:1, col:13)
Skipping function transform::invR(transform_pb2.Rotation2f a). Error reported from parser was: Expected ')', found '.'  (at char 14), (line:1, col:15)

These parsing messages can overwhelm the console and mask users from seeing valuable error or warning messages provided by Sphinx

@JasperCraeghs JasperCraeghs self-requested a review February 6, 2025 14:45
Copy link
Collaborator

@JasperCraeghs JasperCraeghs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this contribution. Instead of a boolean, we could support a list of regular expressions instead, for added granularity. What do you think?

This project has received contributions that we recently merged to the master branch but have not yet been released. These contributions will likely get rid of many of the parser warnings tnat you encounter. I will try to reach out to the owner of this repository again to make a release.

@JasperCraeghs
Copy link
Collaborator

FYI We have released version 1.12.4 this evening.

I triggered the unit tests in CI and some of them require an update. If you want any help, let me know. 🙂

@dambrosio
Copy link
Contributor Author

FYI We have released version 1.12.4 this evening.

I triggered the unit tests in CI and some of them require an update. If you want any help, let me know. 🙂

I can test this out to see if it fixes some of the parse exceptions in our code base.

@dambrosio
Copy link
Contributor Author

Thanks for this contribution. Instead of a boolean, we could support a list of regular expressions instead, for added granularity. What do you think?

I would be down to change this behavior. Are you thinking a single regex or multiple regexs? Would the idea be to match specific text inside of the ParseException error message?

ie.

Skipping function company::DEFINE_string(logs_directory, "", "Path to the directory."). Error reported from parser was: Expected ')', found ','  (at char 15), (line:1, col:16)

So we could add a regex that would be something like company::DEFINE to only match specific member_kind, member_symbol or arglist values?

@dambrosio
Copy link
Contributor Author

FYI We have released version 1.12.4 this evening.
I triggered the unit tests in CI and some of them require an update. If you want any help, let me know. 🙂

I can test this out to see if it fixes some of the parse exceptions in our code base.

I still see parse exceptions in our code base. I think some are probably due to our usage of gflags as well as selectively including specific source for documentation. In either case, I still think having a mechanism to disable these prints would be helpful from our end.

@dambrosio dambrosio force-pushed the 55-ignore-parse-exception-print branch from d7f822b to 6a1d432 Compare February 7, 2025 18:10
@dambrosio
Copy link
Contributor Author

dambrosio commented Feb 7, 2025

@JasperCraeghs I updated with the regex approach. Here are my local repo test results:

Default for doxylink_parse_exception_ignore_regex_list

Skipping function company::DEFINE_bool(show, false, "Enable visualization"). Error reported from parser was: Expected ')', found ','  (at char 12), (line:1, col:13)
...
Skipping function company::anonymous_namespace{builder.cc}::kRange3D(8.f, 8.f, 3.f). Error reported from parser was: Expected ')', found '.'  (at char 2), (line:1, col:3)
...
Skipping function transform::getAngle(transform_pb2.Rotation2f rot). Error reported from parser was: Expected ')', found '.'  (at char 14), (line:1, col:15)
...

With the following doxylink_parse_exception_ignore_regex_list = [r".*DEFINE.*", r".*anonymous_namespace.*"]

Ignoring parsing exceptions using `re.compile('.*DEFINE.*|.*anonymous_namespace.*')`
...
Skipping function transform::getAngle(transform_pb2.Rotation2f rot). Error reported from parser was: Expected ')', found '.'  (at char 14), (line:1, col:15)
...

@JasperCraeghs
Copy link
Collaborator

JasperCraeghs commented Feb 26, 2025

  • I replaced print with report_warning so that it becomes a proper Sphinx warning that can be converted into an error with sphinx-build -W
  • Combining the regex patterns with | without grouping (with parentheses) may lead to unexpected results, I think. I chose to evaluate each regex one by one. Python stores the compiled patterns in cache.
  • I added a test case.
  • I renamed the configuration variable doxylink_parse_exception_ignore_regex_list to doxylink_parse_error_ignore_regexes. I'll update the PR description to reflect our recent changes.

Please review my contribution.

@dambrosio
Copy link
Contributor Author

  • I replaced print with report_warning so that it becomes a proper Sphinx warning that can be converted into an error with sphinx-build -W
  • Combining the regex patterns with | without grouping (with parentheses) may lead to unexpected results, I think. I chose to evaluate each regex one by one. Python stores the compiled patterns in cache.
  • I added a test case.
  • I renamed the configuration variable doxylink_parse_exception_ignore_regex_list to doxylink_parse_error_ignore_regexes. I'll update the PR description to reflect our recent changes.

Please review my contribution.

Thanks for updating this @JasperCraeghs, your changes look great 🎉!

When this merges do you have a plan for what the release timeline looks like?

Cheers!

@JasperCraeghs JasperCraeghs merged commit c4cb659 into sphinx-contrib:master Feb 28, 2025
5 checks passed
@JasperCraeghs
Copy link
Collaborator

Released as 1.13.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants